<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>固定资产</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
</head>
<body>
	<div id="msg" align="center" style="padding-top: 40px;">
		正在验证物料编码……</div>
	<script type="text/javascript">
	
		var upWindow = window.parent.frames["zwIframe"];
		var designClass = "design_class", hideClass = "hide_class", browseClass = "browse_class", addClass = "add_class", editClass = "edit_class";
	
		function fy_dialog_close() {
			window.parent.$(".mask").remove();
			window.parent.parent.$(".layui-layer-iframe").parent().find(".layui-layer-close").trigger("click");
		
		}
		function getUpFieldsByFieldval(name) {
			return upWindow.$("[fieldval*='displayName:\"" + name + "\"']");
			
		}

		function getUpFieldValue(field) {
		
			var fieldVal = field.attr("fieldVal");
			var editTag = field.hasClass(editClass);
			var browseTag = field.hasClass(browseClass);
			var addTag = field.hasClass(addClass);
			if (fieldVal != null && typeof (fieldVal) != 'undefined') {
				fieldVal = eval("(" + fieldVal + ")");
			} else {
				return null;
			}
			var obj = new Object();
			obj.displayName = fieldVal.displayName;
			obj.name = fieldVal.name;
			var tag = true;
			switch (fieldVal.inputType) {
			case "text":
			case "textarea":
				if (editTag) {
					obj.value = field.find("#" + fieldVal.name).val();
				} else if (browseTag) {
					obj.value = fieldVal.value;
				} else if (addTag) {
					obj.value = field.find("#" + fieldVal.name).val();
				}
				break;
			default:
				tag = false;
			}
			if (obj.value != undefined) {
				obj.value = obj.value.replace("\r\n", ";");
				obj.value = obj.value.replace("\n", ";");
			}
			return obj;
		}

		function setUpFieldValue2(field, value, displayValue, index) {
		
			var fieldVal = field.attr("fieldVal");
			var editTag = field.hasClass(editClass);
			var browseTag = field.hasClass(browseClass);
			var addTag = field.hasClass(addClass);
			if (fieldVal != null && typeof (fieldVal) != 'undefined') {
				fieldVal = eval("(" + fieldVal + ")");
			} else {
				return null;
			}
			var tag = true;
			switch (fieldVal.inputType) {
			case "text":
			case "textarea":
				if (editTag) {
					field.find("#" + fieldVal.name).val(value);
					field.find("#" + fieldVal.name).trigger("blur");
				} else if (addTag) {
					field.find("#" + fieldVal.name).val(
							field.find("#" + fieldVal.name).val() + value);
					field.find("#" + fieldVal.name).trigger("blur");
				}
				break;
			case "date":
				if (editTag) {
					field.find("#" + fieldVal.name).val(value);
					field.find("#" + fieldVal.name).trigger("blur");
				}
				break;
			}
		}

		var fiexdCode = [];
		var lineCode = [];
		var xmlObj = null;
		//var DifferentiateForm = false
		
		<!--固定资产验收表-->
		var fiexdCodeInputArray = getUpFieldsByFieldval("设备条码");
		var fiexdModelInputArray = getUpFieldsByFieldval("规格型号");
		var fiexdSuppInputArray = getUpFieldsByFieldval("供应商");
		var fiexdTypeInputArray = getUpFieldsByFieldval("设备类型-重复表");
		var fiexdLineInputArray = getUpFieldsByFieldval("生产线名称");
		<!--固定资产转移表-->
		var fiexdOldLineInputArray = getUpFieldsByFieldval("原生产线");
		var fiexdLineCodeInputArray = getUpFieldsByFieldval("原生产线代码");
		
		var fiexdNewLineInputArray = getUpFieldsByFieldval("转入生产线");
		var fiexdNewLineCodeInputArray = getUpFieldsByFieldval("转入生产线代码");
		<!--设备调用清单-->
		
		var fiexdModelInputArray2 = getUpFieldsByFieldval("设备型号");
		var fiexdNameInputArray = getUpFieldsByFieldval("设备名称");
		
		
	//	var fiexdEquipmentNameArray = getUpFieldsByFieldval("设备名称");
	//	var fiexdEquipmentModelArray = getUpFieldsByFieldval("设备型号");

		/* var newMaterialCodeInputArray = getUpFieldsByFieldval("需改成的编码");
		var newMaterialDescribeInputArray = getUpFieldsByFieldval("需改成的说明");
		var newMaterialDescribeEnInputArray = getUpFieldsByFieldval("英文需修改成的说明");
		var newMaterialMeasurementInputArray = getUpFieldsByFieldval("需修改成的单位"); */

		if (fiexdCodeInputArray.length > 0) {
			
			length = fiexdCodeInputArray.length;
			
		} 

		function init() {
	
			for (var i = 0; i < length; i++) {

				fiexdCode.push(getUpFieldValue(fiexdCodeInputArray.eq(i)).value);
				setUpFieldValue2(fiexdModelInputArray.eq(i), "");
				setUpFieldValue2(fiexdSuppInputArray.eq(i), "");
				setUpFieldValue2(fiexdTypeInputArray.eq(i), "");
				setUpFieldValue2(fiexdLineInputArray.eq(i), "");	
					
				setUpFieldValue2(fiexdLineCodeInputArray.eq(i), "");
				setUpFieldValue2(fiexdNewLineInputArray.eq(i), "");
				
				

				
				if(fiexdNewLineCodeInputArray.length>0){				
				lineCode.push(getUpFieldValue(fiexdNewLineCodeInputArray.eq(i)).value);
				}else{
				setUpFieldValue2(fiexdNewLineCodeInputArray.eq(i), "");
				}
				
				
				setUpFieldValue2(fiexdModelInputArray2.eq(i), "");
				setUpFieldValue2(fiexdNameInputArray.eq(i), "");
				//setUpFieldValue2(fiexdNewLineCodeInputArray.eq(i), "");
				//lineCode.push(getUpFieldValue(fiexdNewLineCodeInputArray.eq(i)).value);

			}
		}

		function load() {
	
			if (window.XMLHttpRequest) {
				xmlObj = new XMLHttpRequest();
			} else {
				if (window.ActiveXObject) {
					xmlObj = new ActiveXObject("Microsoft.XMLHTTP");//java定义XMLHTTP对象的方法
				} else {
					return;
				}
			}
			xmlObj.onreadystatechange = handleResponse;
			xmlObj.open("get",
					"./oa2mdmController.do?method=writeFiexdAssetsInfoJSP&fiexdCode="
							+ fiexdCode.join(",") + "&lineCode="+lineCode.join(","), true);
			
			xmlObj.send();//发送
			//alert(fiexdCode.join(","));

		}

		function handleResponse() {
			//alert(xmlObj.readyState+"99");
			if (xmlObj.readyState == 4) {//xmlObj loaded
				var success = false;
				//alert(xmlObj.status+"@@");
				if (xmlObj.status == 200) {
				//alert(xmlObj.responseText+"##");
					var datas = eval("[" + xmlObj.responseText + "]");
					
				//alert(datas.length+"()");
					if (datas.length == 1) {
						var materialMap = datas[0];
						
						
						for (var i = 0; i < length; i++) {
							
								var material = materialMap["assetBarcode"
										+ getUpFieldValue(fiexdCodeInputArray
												.eq(i)).value];
//alert(material+"5");
								if (material) {
									setUpFieldValue2(fiexdModelInputArray
											.eq(i), material["assetSpeModel"]);//规格/型号

									setUpFieldValue2(fiexdSuppInputArray
											.eq(i), material["assetName"]);// 供应商名称
					
									setUpFieldValue2(fiexdTypeInputArray
											.eq(i), material["assetsName"]);	// 设备类型
	
									setUpFieldValue2(fiexdLineInputArray
											.eq(i), material["lineName"]);	// 生产线名称
									setUpFieldValue2(fiexdLineCodeInputArray
											.eq(i), material["lineCode"]);	// 生产线代码
									setUpFieldValue2(fiexdOldLineInputArray
											.eq(i), material["lineName"]);	// 原生产线名称
								if(fiexdNewLineCodeInputArray.length>0){
								setUpFieldValue2(fiexdNewLineInputArray
								.eq(i), material["newLineName"]);	// 生产线名称
								setUpFieldValue2(fiexdNewLineCodeInputArray
								.eq(i), material["newLineCode"]);	// 生产线代码
											}
									setUpFieldValue2(fiexdModelInputArray2
											.eq(i), material["assetSpeModel"]);//设备型号
									setUpFieldValue2(fiexdNameInputArray
											.eq(i), material["assetsName"]);//设备名称											

								}
							
							success = true;
						}

					}
				}
				if (!success) {
					alert("请检查输入的固定资产 ");
				}
				fy_dialog_close();
			}

		}
		init();//初始化
		load();//加载
	</script><html></html>
</body>
</html>

